# -*- coding: utf-8 -*-
#!/usr/bin/env python

#@Author: TDZ
#@Email : 409358374@qq.com
#@time: 2020/05/21





# QtWidgets.QApplication.activeWindows() --> 获取当前激活的qt窗口对象.

# QtWidgets.QApplication.allWidgets() --> 获取现存于内存中的所有qt对象,以列表形式返回.


## Maya Template
from Qt import QtGui, QtCore, QtWidgets
import maya.OpenMayaUI as omui

try:
    import shiboken
except Exception:
    try:
        import shiboken2 as shiboken
    except Exception:
        print("shiboken module does not exist !")


def get_mayaMainUI():
    prt = omui.MQtUtil.mainWindow()
    return shiboken.wrapInstance(long(prt), QtGui.QWidget)


class Main_UI(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(Main_UI, self).__init__(parent=parent)
        self.setWindowFlags(QtCore.Qt.Dialog)
        self.setWindowTitle("Tool Name")   # 窗口名字
        self.main_layout = QtWidgets.QVBoxLayout(self)
        # Qt代码


def main():
    global handle
    try:
        handle.close()
        handle.deleteLater()
    except:
        pass
    handle = Main_UI(parent=get_mayaMainUI())
    handle.show()


if __name__ == "__main__":
    main()




## Nuke Template
from Qt import QtGui, QtCore, QtWidgets

class Main_UI(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(Main_UI, self).__init__(parent=parent)
        self.setWindowFlags(QtCore.Qt.Dialog)
        self.setWindowTitle("Tool Name")   # 窗口名字
        self.main_layout = QtWidgets.QVBoxLayout(self)
        # Qt代码


def main():
    global handle
    try:
        handle.close()
        handle.deleteLater()
    except:
        pass
    nuke_main_windows = QtWidgets.QApplication.activeWindow()
    handle = Main_UI(parent=nuke_main_windows)
    handle.show()


if __name__ == "__main__":
    main()
